package com.then.libary.util;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class LoopQueue<T> implements Serializable{
	private int front = 0;
	private int back = 0;
	List<T> ts;
	public LoopQueue(){
		ts = new ArrayList<T>();
		
	}
	public  T dequeue()
	{
		if (ts.size()==0) {
			return null;
		}
		if (front==back) {
			front=0;
		}
		T t = ts.get(front);
		front++;
		return t;
	}
	public void add(T t)
	{
		ts.add(t);
		back++;
	}
}
